package com.becca.cake.model.order;

import java.io.Serializable;
import java.util.Date;

import org.apache.commons.lang.StringUtils;

import com.becca.cake.core.exception.ServiceException;

/**
 * 订单退款model
 * @author mouwanming
 *
 */
public class OrderRefundsModel implements Serializable
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	 /**退款状态(0:待退款）*/
    public static final Byte        REFUNDS_STATUS_WAIT        = 0;
    /**退款状态(1:退款中）*/
    public static final Byte        REFUNDS_STATUS_CONFIRM     = 1;
    /**退款状态(2:已退款 ）*/
    public static final Byte        REFUNDS_STATUS_CONFIRMED   = 2;
    /**退款状态(3:已拒绝 ）*/
    public static final Byte        REFUNDS_STATUS_REFUSED     = 3;
    /**退款金额不能为空*/
    public static final String      REFUNDS_PRICE_IS_NULL     = "退款金额不能为空";
    /**订单来源不能为空*/
    public static final String      ORDERID_IS_NULL       = "订单来源不能为空";
    /**退款状态不能为空*/
    public static final String        REFUNDS_STATUS      = "退款状态不能为空";
    
	
	private Integer 	id;
	/**订单Id*/
	private Integer     orderId;
	/**退款原因*/
	private String      refundsReason;
	/**退款价格*/
	private double      refundsPrice;
	/**退款状态*/
	private Byte        refundsStatus;
	/**拒绝原因*/
	private String      refusedReason;
	/**创建时间*/
    private Date        createdDate;
    /**创建人*/
    private String      createdName;
    /**修改时间*/
    private Date        updatedDate;
    /**修改人*/
    private String      updatedName;
    /**申请退款前订单状态(0:待付款 1:确认中 2:已确认 3:备货中 4:已发货 5:已完成 6:已取消)*/
    private Byte    	beforeRefundOrderStatus;
    /**订单编码*/
    private String  	orderCode;
    
	public Integer getId()
	{
		return id;
	}
	public void setId(Integer id)
	{
		this.id = id;
	}
	public Integer getOrderId()
	{
		return orderId;
	}
	public void setOrderId(Integer orderId)
	{
		this.orderId = orderId;
	}
	public String getRefundsReason()
	{
		return refundsReason;
	}
	public void setRefundsReason(String refundsReason)
	{
		this.refundsReason = refundsReason;
	}
	public double getRefundsPrice()
	{
		return refundsPrice;
	}
	public void setRefundsPrice(double refundsPrice)
	{
		this.refundsPrice = refundsPrice;
	}
	public Byte getRefundsStatus()
	{
		return refundsStatus;
	}
	public void setRefundsStatus(Byte refundsStatus)
	{
		this.refundsStatus = refundsStatus;
	}
	public String getRefusedReason()
	{
		return refusedReason;
	}
	public void setRefusedReason(String refusedReason)
	{
		this.refusedReason = refusedReason;
	}
	public Date getCreatedDate()
	{
		return createdDate;
	}
	public void setCreatedDate(Date createdDate)
	{
		this.createdDate = createdDate;
	}
	public String getCreatedName()
	{
		return createdName;
	}
	public void setCreatedName(String createdName)
	{
		this.createdName = createdName;
	}
	public Date getUpdatedDate()
	{
		return updatedDate;
	}
	public void setUpdatedDate(Date updatedDate)
	{
		this.updatedDate = updatedDate;
	}
	public String getUpdatedName()
	{
		return updatedName;
	}
	public void setUpdatedName(String updatedName)
	{
		this.updatedName = updatedName;
	}
	public Byte getBeforeRefundOrderStatus()
	{
		return beforeRefundOrderStatus;
	}
	public void setBeforeRefundOrderStatus(Byte beforeRefundOrderStatus)
	{
		this.beforeRefundOrderStatus = beforeRefundOrderStatus;
	}
	public String getOrderCode()
	{
		return orderCode;
	}
	public void setOrderCode(String orderCode)
	{
		this.orderCode = orderCode;
	}
	/**
     * 退款数据校验
     * @param orderId
     * @param orderStatus
     * @param statusName
     * @return
     */
    public static void validateRefundsPrice(String orderIds, Double refundsPrice) {
        if (StringUtils.isEmpty(orderIds)) {
            throw new ServiceException(OrderRefundsModel.ORDERID_IS_NULL);
        }
        if (refundsPrice == null) {
            throw new ServiceException(OrderRefundsModel.REFUNDS_PRICE_IS_NULL);
        }
    }
    
	/**
     * 退款数据校验
     * @param orderId
     * @param orderStatus
     * @param statusName
     * @return
     */
    public static void validateRefundsStatus(String orderIds, Byte refundsStatus) {
        if (StringUtils.isEmpty(orderIds)) {
            throw new ServiceException(OrderRefundsModel.ORDERID_IS_NULL);
        }
        if (refundsStatus == null) {
            throw new ServiceException(OrderRefundsModel.REFUNDS_STATUS);
        }
    }
    
	@Override
    public String toString() {
        return "OrderDO [id=" + id + ", orderId=" + orderId + ", refundsReason=" + refundsReason
               + ", refundsPrice=" + refundsPrice + ", refundsStatus=" + refundsStatus
               + ", refusedReason=" + refusedReason + ", createdDate=" + createdDate + ", createdName=" + createdName
               + ", updatedDate=" + updatedDate + ", updatedName=" + updatedName + "]";
    }
    

}
